import {
  Bind,
  Body,
  Controller,
  Get,
  Query,
  UseFilters,
  UsePipes,
  UseGuards,
  UseInterceptors,
} from '@nestjs/common';
import { AppService } from './app.service';
import { TestPipe } from './pipe/test.pipe';
import { ScheduleService } from './schedule/schedule.service';
import { TestGuard } from './guard/test.guard';
import { TestInterceptor } from './interceptors/test.interceptors';
import { User } from './decorator/test.decorator';
import { HttpExceptionFilter } from './filter/exception.filter';

@Controller()
@UseGuards(TestGuard)
@UseInterceptors(TestInterceptor)
@UseFilters(HttpExceptionFilter)
export class AppController {
  constructor(
    private readonly appService: AppService,
    private scheduleService: ScheduleService,
  ) {
    // this.scheduleService.handleCron() // 无需调用服务器会自己启动定时器
  }

  @Get()
  getHello(
    @Query('id', TestPipe) id: string,
    @User({ a: 1 }) userId: string,
  ): string {
    return this.appService.getHello();
  }
}
